/*
 * @Descripttion:
 * @TapdLink: https://XXX
 * @DesignsLink: https://XXX
 * @RelatedPersons: XXX[市场]、XXX[产品]、XXX[前端]、XXX[后端]、XXX[设计]
 * @version: 1.0.0
 * @Author: Shentong
 * @LastEditors: shentong
 * @Date: 2021-09-24 11:32:10
 */
import { server } from './server'


interface ISwiperBannerResponse {
  data?: DSwiperData
}
interface DSwiperData {
  images: Array<any>
  cates: Array<any>
}

// 商品列表
export const getOrderList = (params) => {
  const { queryType = 0, pageNo = 1, pageSize = 20} = params
  return server.POST<any, any>(`/order/page?queryType=${queryType}&pageNo=${pageNo}&pageSize=${pageSize}`)
}
interface IorderDetailRequst {
  orderId: string | number;
}

interface IwxPayRequst {
  orderNumber: string | number;
  bizType: number; // 0:外卖订单  1:抽奖订单(默认外卖订单)
}

interface IShopCommentRequest {
  shopId: string;
  pageNo: number;
  pageSize: number;
}

interface IOrderReminderReq {
  orderId: string
}

interface IOrderRefundReq {
  orderId: string;
  reason: string;
}

// 订单详情页
export const getOrderDetail = (params) => {
  return server.POST<IorderDetailRequst, ISwiperBannerResponse>(`/order/detail?orderId=${params.orderId}`)
}
// 提交订单
export const submitOrder = (params) => {
  return server.POST<IorderDetailRequst, ISwiperBannerResponse>(`/order/wx/submit`, params)
}

// 提交订单页-结算明细
export const gettlement = (params) => {
  return server.POST<any, any>(`/order/settlement`, params)
}
// 商户当前下单时间
export const shopOrderDate = (params) => {
  return server.POST<any, any>(`/shop/order/date?shopId=${params.shopId}&userAddressId=${params.userAddressId}`)
}
// 微信支付 /wxpay/topay
export const wxPay = (params: IwxPayRequst) => {
  const { orderNumber, bizType = 0} = params
  return server.POST<IwxPayRequst, any>(`/wxpay/topay?orderNumber=${orderNumber}&bizType=${bizType}`)
}
// 商户评价
export const shopComment = (params: IShopCommentRequest) => {
  const { shopId, pageNo = 1, pageSize = 20} = params
  return server.POST<IShopCommentRequest, any>(`/shop/evaluate/page?shopId=${shopId}&pageSize=${pageSize}&pageNo=${pageNo}`)
}
// 催单
export const reminder = (params: IOrderReminderReq) => {
  return server.POST<IOrderReminderReq, any>(`/order/reminder?orderId=${params.orderId}`)
}
// 退款申请
export const refund = (params: IOrderRefundReq) => {
  return server.POST<IOrderRefundReq, any>(`/order/refund/apply?orderId=${params.orderId}&reason=${params.reason}`)
}
// 抽奖活动
export const luckCardActivity = () => {
  return server.POST<IOrderRefundReq, any>(`/lottery/order/types`)
}
// 用户可用抽奖次数
export const luckCardUserCount = () => {
  return server.POST<IOrderRefundReq, any>(`/lottery/user/count`)
}
// 提交抽奖订单
export const submitCardActivity = (params) => {
  return server.POST<any, any>(`/lottery/order/submit?orderType=${params.orderType}`)
}
// 抽奖动作
export const doDraw = (params) => {
  return server.POST<any, any>(`/lottery/draw?lon=${params.lon}&lat=${params.lat}&schoolId=${params.schoolId}`)
}
// 取餐码对应的二维码
export const getEatQrcode = (params) => {
  return server.POST<any, any>(`/create/qrCode?orderId=${params.orderId}`)
}



//结算明细
// const demoParams = () => {
//   return {
//     deliveryType: 1, //  配送类型（送货到家：1，固定取餐：2）
//     diningPointsId: 1, // 固定取餐点Id
//     items: [
//       {
//         goodsId: '1439799613703557120', // 商品id ,
//         goodsNum: 2, // 购买数量
//         goodsSpecId: '1439799613716140032', //  商品规格id ,
//         propertys: [
//           {
//             propertyId: '1439799613728722944', // 属性id
//             propertyValueId: '1439799613728722945' // 属性值id
//           },
//           {
//             propertyId: '1439799613741305856', // 属性id
//             propertyValueId: '1439799613749694464' // 属性值id
//           }
//         ]
//       },
//       {
//         goodsId: '1439799613703557120', // 商品id ,
//         goodsNum: 1, // 购买数量
//         goodsSpecId: '1439799613716140033', //  商品规格id ,
//         propertys: [
//           {
//             propertyId: '1439799613741305856', // 属性id
//             propertyValueId: '1439799613749694465' // 属性值id
//           }
//         ]
//       },
//       {
//         goodsId: '1075619814015504384', // 商品id ,
//         goodsNum: 3, // 购买数量
//         goodsSpecId: '', //  商品规格id ,
//         propertys: [
//           {
//             propertyId: '1075619814028087296', // 属性id
//             propertyValueId: '1075619814028087297' // 属性值id
//           }
//         ]
//       }
//     ],
//     shopId: '1067621941743255552', // 商户id
//     userCouponId: '', // 用户优惠券id ,
//     userRedPacketId: '' // 用户红包id
//   }

//  }
